home *** CD-ROM | disk | FTP | other *** search
- #include <basepage.h>
- #include "gemlib/gemfast.h"
- #include "gemlib/aesbind.h"
- #include "lackfs.h"
- #include "filesys.h"
- #undef gem /* Why the hell is this defined anyway? And why is it being
- * even in strings? */
-
- #define M_CORE 0x01 /* region came from core map */
- #define M_ALT 0x02 /* region came from alt map */
- #define M_NEWPROT 0x08 /* change mem protection of existing region */
- #define M_PROTMODE 0xf0 /* protection mode bits */
- #define M_PROT_P 0x00 /* no read or write */
- #define M_PROT_G 0x10 /* any access OK */
- #define M_PROT_S 0x20 /* any super access OK */
- #define M_PROT_PR 0x30 /* any read OK, no write */
- #define M_PROT_I 0x40 /* invalid page */
- #define M_KEEP 0x0100 /* don't free on process termination */
-
- /* oy, all this stuff needs to be included for the damn lap structure to
- * be declared
- */
-
- /* a FEW structers: */
-
- /* Oh boy, an undocumented aes feature! */
- struct appl
- {
- struct appl *next;
- long junk; /* I have no idea */
- struct save_area *save_area; /* see trap2.c */
- char name[8]; /* not null terminated, filled with spaces */
- long junk2[2]; /* I know the rsc and menu pointers are in
- * here somewhere, maybe here -- no.
- */
- int apid; /* at offset 1c */
- };
-
- #define evnt_que ((struct appl * volatile * volatile)0xa78e)
- #define run_que ((struct appl * volatile * volatile)0xa792)
- /* I don't know why both these volatiles are nessicary, but they seem to be. */
- /* How can the constant 0xa792 be volatile anyway? */
- #define cur_apid ((*(run_que))->apid)
- #define aes_appl (*(run_que))
- #define appl_waiting ((char *)0xa81e)
-
- #define NUM_APPS 8
-
- #define NULL (void *)0
- #define TRUE 1
- #define FALSE 0
-
-
- struct lacc
- {
- int free;
- int pid;
- OBJECT *menu; /* let's not deal with that quite yet */
- BASEPAGE *base;
- AESP *old_call;
- int menu_index;
- char menu_title[23];
- char name[9];
- char myname[9];
- int isprg;
- };
-
- typedef struct lapplication
- {
- long istk, mystk; /* interupt stack pointer, lack's ssp */
- long regs[13]; /* d1-d7/a2-a7 d1 contains sr */
- long jmppc;
- long jmpusp;
- long mystk_base; /* the start of lack's stack */
- unsigned long mask; /* signals returned by sigblock */
- AESP *call;
- struct lacc *acc;
- int update;
- struct wind *windows; /* see wind.c */
- void (*pc)(); /* This is sort of fucked. When the desktop is
- * active, or lack has just started up, this is
- * the value of the pc we intercepted from gem's
- * internal variables, otherwise, this is a pointer
- * to the pc on the initial trap 2 exeception, and
- * is used in unload_acc().
- */
- int in_aes; /* # of trap 2 calls it has to return from */
- int action;
- }lap;
-
- struct global_action
- {
- int type;
- int apid;
- struct global_action *next;
- };
-
- #define GL_SEND_KILL 1 /* send apid a message to coaxe it out of evnt_multi
- * and let parent eliminate it */
-
- /* apid specific actions, and aes commands */
- /* For aes commands actions are executed after leaving the aes, those
- * commands with no action are handled before (or rather than) entering the
- * aes.
- */
- #define APPL_ALIVE 1 /* apid 0 makes a call after AC_CLOSE */
- #define APPL_KILL 2 /* kill this acc. As an aes command: this acc has
- * been effectively killed, the aes call in progress
- * should return immediately. (The return pc has
- * been altered).
- */
- #define APPL_INIT 10 /* upgrade gl_version to 1.04, gl_apcount to 8. */
- #define APPL_YIELD 17 /* 0xf084 */
- #define APPL_EXIT 19 /* may exit to desktop, ignored if not apid 0. */
- #define MENU_BAR 30 /* No action, ignored if not apid 0. */
- #define MENU_REGISTER 35 /* No action, arg copied over old menu item. */
- #define MENU_UNREGISTER 36 /* No action, menu item says " name <blank>:. */
- #define WIND_CREATE 100 /* Save window handle for wind_new emulation. */
- #define WIND_OPEN 101 /* " */
- #define WIND_CLOSE 102 /* " */
- #define WIND_DELETE 103 /* No action, window handle removed before aes call
- * goes through.
- */
- #define WIND_UPDATE 107 /* adjust curapp->update for wind_new emulation */
- #define WIND_NEW 109 /* No action, makes wind_delete calls then returns
- * to user.
- */
- #define RSRC_LOAD 110
- #define RSRC_FREE 111
- #define SHEL_FIND 124
- #define SHEL_ENVRN 125
-
- /* here is how I declare the kernal funcs, not only does it provide prototypes
- * but it saves a wopping four or eight clock cycles on each call
- */
- #define ki extern const struct kerinfo *const kernal
- /* let me try to cast these damn _LongFuncs
- #define kmshrink void(*m_shrink)(short, void *, long)=kernal->dos_tab[0x4a]
- #define kpexec long(*p_exec)(short, char *, void *, void *)=kernal->dos_tab[0x4b]
- #define ksyield void(*s_yield)(void)=kernal->dos_tab[0xff]
- #define kpgetpid int (*p_getpid)(void)=kernal->dos_tab[0x10b]
- #define kpdomain int (*p_domain)(int)=kernal->dos_tab[0x119]
- */
- #define kMalloc void *(*m_alloc)(long size)=(void *(*)())kernal->dos_tab[0x48]
- #define kmshrink void(*m_shrink)(short, void *, long)=(void (*)())kernal->dos_tab[0x4a]
- #define kpexec long(*p_exec)(short, char *, void *, void *)=(long (*)())kernal->dos_tab[0x4b]
- #define ksyield void(*s_yield)(void)=(void (*)())kernal->dos_tab[0xff]
- #define kpwait long(*p_wait)(void)=(long(*)())kernal->dos_tab[0x109]
- #define kpgetpid int (*p_getpid)(void)=(int (*)())kernal->dos_tab[0x10b]
- #define kpsigblock long (*p_sigblock)(long)=(long (*)())kernal->dos_tab[0x116]
- #define kpsigsetmask long (*p_sigsetmask)(long)=(long (*)())kernal->dos_tab[0x117]
- #define kpdomain int (*p_domain)(int)=(int (*)())kernal->dos_tab[0x119]
- #define kpmsg long (*p_msg)(short, long, struct msg *)=(long (*)())kernal->dos_tab[0x125]
- #define kprenice int (*p_renice)(int, int)=(int (*)())kernal->dos_tab[0x127]
- #define ktgettime int (*t_gettime)(void)=(int (*)())kernal->dos_tab[0x2c]
- #define ktgetdate int (*t_getdate)(void)=(int (*)())kernal->dos_tab[0x2a]
- #define TRACE kernal->trace
- #define DEBUG kernal->debug
- #define ALERT kernal->alert
- #define kmalloc kernal->kmalloc
- #define kfree kernal->kfree
- #define sleep kernal->sleep
- #define wake kernal->wake
- #define ksprintf kernal->sprintf
- #define IO_Q 3
- #define spl7() \
- ({\
- short retval;\
- \
- asm(" movw sr, %0; \
- oriw #0x700, sr" \
- :"=d"(retval));\
- retval;\
- })
- #define spl(sr) \
- ({\
- asm(" movw %0,sr"::"d"(sr));\
- })
-